package org.example.myframework.frame.demo.domain.base;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @name: 分页返回封装类
 * @author: xyy
 * @create: 2021/5/10 18:06
 * @description: 分页数据返回结果
 */
@ApiModel(value = "分页数据返回结果", description = "分页数据返回结果")
@Data
public class PageVo<T> implements Serializable {

    private static final long serialVersionUID = -3618064417599357871L;

    @ApiModelProperty(value = "数据总条数")
    private Long totalCount;

    @ApiModelProperty(value = "总页码")
    private Long totalPage;

    @ApiModelProperty(value = "当前页面")
    private Long pageIndex = 1L;

    @ApiModelProperty(value = "每页条数")
    private Long pageSize = 10L;

    @ApiModelProperty(value = "结果数据")
    private List<T> records;

    /**
     * 无参构造
     */
    public PageVo() {

    }

    /**
     * 简单分页构造
     * @param totalCount
     * @param totalPage
     * @param records
     */
    public PageVo(Long totalCount, Long totalPage, List<T> records) {
        this.totalCount = totalCount;
        this.totalPage = totalPage;
        this.records = records;
    }

    /**
     * 全参构造
     * @param totalCount
     * @param totalPage
     * @param pageIndex
     * @param pageSize
     * @param records
     */
    public PageVo(Long totalCount, Long totalPage, Long pageIndex, Long pageSize, List<T> records) {
        this.totalCount = totalCount;
        this.totalPage = totalPage;
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.records = records;
    }

}
